package com.yuyu.shop.infrastructure.persistence.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yuyu.shop.domain.user.DO.ReceiveInfoDO;
import com.yuyu.shop.domain.user.repository.ReceiveInfoRepository;
import com.yuyu.shop.infrastructure.persistence.convert.ReceiveInfoPoConvert;
import com.yuyu.shop.infrastructure.persistence.mapper.ReceiveInfoMapper;
import com.yuyu.shop.infrastructure.persistence.po.ReceiveInfoPO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author
 * @version 1.0
 * @description: TODO
 * @date 2022/8/31 18:02
 */
@Service
public class ReceiveInfoRepositoryImpl implements ReceiveInfoRepository {

    @Resource
    private ReceiveInfoMapper receiveInfoMapper;

    @Override
    public List<ReceiveInfoDO> queryReceiveInfos(Long userId) {
        List<ReceiveInfoPO> receiveInfoPOS = receiveInfoMapper.selectList(new LambdaQueryWrapper<ReceiveInfoPO>().eq(ReceiveInfoPO::getUserId, userId));
        return receiveInfoPOS.stream().map(ReceiveInfoPoConvert::PO2DO).collect(Collectors.toList());
    }
}
